<template>
    <div class="demo">
        <h1>当前求和为{{$store.state.count}}</h1>
        <select v-model="n">
            <option :value="1">1</option>
            <option :value="2">2</option>
            <option :value="3">3</option>
        </select>
        <button @click="add">+</button>
        <button @click="jian">-</button>
        <button @click="odd">+</button>
        <button @click="waitadd">等一等在加</button>
    </div>
</template>
<script>
    export default {
        name: 'SchoolN',
        data() {
            return {
                n: 1,
                count: 0
            }
        }, props: ['title'],
        methods: {
            add() {
                this.$store.commit('JIA', this.n)
            },
            jian() {
                this.$store.commit('JIAN', this.n)
            },
            odd() {
                this.$store.dispatch('odd', this.n)

            },
            waitadd() {
                this.$store.dispatch('waitadd', this.n)
            }
        },
    }
</script>

<style scoped>
    .demo {
        width: 300px;
        height: 400px;
        background-color: skyblue;

    }

    ul {
        list-style: none;
        display: block;
    }
</style>